#pragma once

#include <core/comdefs.h>
#include <widgets/SCheckComboBox.h>
#include <widgets/SLineEdit.h>
#include <QtWidgets/QWidget>
#include <QPushButton>
#include <QTextEdit>
#include <QTimer>

using namespace qb;

struct testCase
{
	int idx;
	unsigned long uBeginTime;
};

class BaseWidget
	: public QWidget
{
	Q_OBJECT
public:
    BaseWidget(QWidget* parent = nullptr);
	~BaseWidget();

protected:
	void paintEvent(QPaintEvent* event) override;
	void resizeEvent(QResizeEvent* event) override;

	void setupUi(QStringList strList);
	void setTimeout(int sec);
	void setInterval(int msec);
	void startTimer();
	void stopTimer();
	void startIntervalTimer();
	void stopIntervalTimer();
	virtual void onTimeout() {}
	virtual void onIntervalTimeout() {}

public slots:
	void onTimer();
	void onIntervalTimer();

protected:
	SCheckComboBox* checkCombo = nullptr;
	SLineEdit* editTimes = nullptr;
	SLineEdit* editTimeout = nullptr;
	SLineEdit* editInterval = nullptr;
	QPushButton* btnRequest = nullptr;
	QPushButton* btnClear = nullptr;
	QTextEdit* editor = nullptr;
	QTimer* mTimer = nullptr;
	QTimer* mIntervalTimer = nullptr;
};
